<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="../vue.js"></script>
    <style>
        .box {
            width: 100px;
            height: 100px;
            background: red;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="box" v-if="num==1">111</div>
        <div class="box" v-else-if="num==2">222</div>
        <div v-else>num是其他</div>
        <button @click="nums">点击</button>
    </div>

    <script>
        new Vue({
            el: "#app",
            data: {
                num: 1,
            },
            methods: {
                nums() {
                    this.num++;
                },
            },
        });
    </script>
</body>

</html>